<?php

class Sistema_Form_Linha extends Zend_Form {

    public function init() {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;

        $this->setName('form_pdr');

        $id = $front->getRequest()->getParam('id', 0);
        $for_id = $front->getRequest()->getParam('for_id', 0);
        
        $url .= '/index/for_id/'.$for_id;
        
        $el = new Zend_Form_Element_Hidden('LIN_ID', array('disableLoadDefaultDecorators' => true));
        $el->addDecorators(array(array('ViewHelper'), array('Errors')))->addFilter('Int');
        $this->addElement($el);

        $el = new Zend_Form_Element_Text('LIN_NOM');
        $el->setLabel('Nome')->setRequired(true);
        $el->setAttrib('required', '');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Checkbox('LIN_STA',array('checked'=>'checked'));
        $el->setLabel('Ativo');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('Salvar', array('disableLoadDefaultDecorators' => true));
        $btn->setLabel('Salvar');
        $btn->addDecorators(array(array('ViewHelper'), array('Errors')));
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);

        $btn = new Zend_Form_Element_Button('Cancelar', array('disableLoadDefaultDecorators' => true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="' . $url . '" class="btn-frm">Voltar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
    }

}
